import type { IPage } from '@/api/interface/index'
import type { IMetaWarehouse } from '@/api/interface/rescue/meta/metaWarehouse'
import { RESCUE_MODULE } from '@/api/helper/prefix'
import { http } from '@/utils/http'

/**
 * 查询列表
 * @param params
 * @returns {*}
 */
export function getMetaWarehouseListApi(params: IMetaWarehouse.Query) {
  return http.get<IPage<IMetaWarehouse.Row>>(`${RESCUE_MODULE}/meta-warehouse/list`, params)
}

/**
 * 获取详情
 * @param params
 * @returns {*}
 */
export function getMetaWarehouseDetailApi(params: { id: number }) {
  return http.get<IMetaWarehouse.Row>(`${RESCUE_MODULE}/meta-warehouse/detail`, params)
}

/**
 * 新增仓库
 * @param data
 * @returns {*}
 */
export function createMetaWarehouseApi(data: IMetaWarehouse.CreateForm) {
  return http.post(`${RESCUE_MODULE}/meta-warehouse/create`, data)
}

/**
 * 更新仓库
 * @param data
 * @returns {*}
 */
export function updateMetaWarehouseApi(data: IMetaWarehouse.UpdateForm) {
  return http.put(`${RESCUE_MODULE}/meta-warehouse/update`, data)
}

/**
 * 删除仓库
 * @param data
 * @returns {*}
 */
export function deleteMetaWarehouseApi(data: IMetaWarehouse.DeleteParams) {
  return http({
    url: `${RESCUE_MODULE}/meta-warehouse/remove`,
    method: 'DELETE',
    data,
  })
}

/**
 * 导入Excel
 * @param data
 * @returns {*}
 */
export function importMetaWarehouseApi(data: FormData) {
  return http.post(`${RESCUE_MODULE}/meta-warehouse/import`, data, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}

/**
 * 导出Excel
 * @param data
 * @returns {*}
 */
export function exportMetaWarehouseApi(data: IMetaWarehouse.Query) {
  return http.post<Blob>(`${RESCUE_MODULE}/meta-warehouse/export`, data, {
    responseType: 'blob',
  })
}
